/**
 * 2017-10-19 by ShiJun Liu
 *  所有ajax请求接口
 * 后期优化：可以使用 C#进行代码生成 指定规则
 *  现部分代码 由代码生成得到
 */
import axios from 'axios';
import { Base64 } from 'js-base64';
// axios.defaults.baseURL = 'http://192.168.30.22/api/';
// var baseUrl = window.location.origin + "/";
// var baseUrl = 'http://192.168.10.14:8099/';
// var baseUrl = 'http://192.168.10.14:8079/';
// var baseUrl = 'http://192.168.30.22/';
var baseUrl = 'http://localhost:16866/';
// var baseUrl = 'http://192.168.10.203:8006/';
axios.defaults.baseURL = baseUrl + 'api';
axios.defaults.headers.post['Content-Type'] = 'application/json';
(function() {
    if (sessionStorage.getItem("Authorization"))
        axios.defaults.headers.common['Authorization'] = "Basic " + sessionStorage.getItem("Authorization");
})()
import {
    mapState
} from "vuex";
export default {
    apiGet(that, url, callback) {
        that.$store.state.loading = true;
        if (url.indexOf("?") > 0) {
            url += "&api-version=1.0"
        } else {
            url += "?api-version=1.0"
        }
        axios.get(url).then(function(response) {
                that.$store.state.loading = false;
                that.loding = false;
                if (response.status == 200) {
                    if (response.data.Code == 1) {
                        return callback(response.data);
                    } else {
                        that.$notify.error({
                            title: '失败',
                            message: '请求失败'
                        });
                    }
                } else {
                    that.$notify.error({
                        title: '失败',
                        message: '网络错误'
                    });
                }

            })
            .catch(function(error) {
                console.log(error);
                if (error.response.status == 401) {
                    that.$router.replace({
                        name: 'Login'
                    });
                    return;
                }
                that.loding = false;
                that.$store.state.loading = false;
                that.$notify.error({
                    title: '失败',
                    message: '网络错误'
                });
            });
    },
    apiPost(that, url, data, callBack) {
        url += "?api-version=1.0";
        that.$store.state.loading = true;
        axios.post(url, data).then(function(response) {
                that.$store.state.loading = false;
                if (response.status == 200) {
                    if (response.data.Code == 1) {
                        return callBack(response.data);
                    } else {

                        that.$notify.error({
                            title: '失败',
                            message: '添加失败'
                        });
                    }
                } else {
                    that.$notify.error({
                        title: '失败',
                        message: '添加失败'
                    });
                }
            })
            .catch(function(error) {
                if (error.response.status == 401) {
                    that.$router.replace({
                        name: 'Login'
                    });
                    return;
                }
                that.$store.state.loading = false;
                that.$notify.error({
                    title: '失败',
                    message: '网络错误'
                });
            });
    },
    apiPut(that, url, data, callBack) {
        url += "?api-version=1.0";
        that.$store.state.loading = true;
        axios.put(url, data).then(function(response) {
                that.$store.state.loading = false;
                if (response.status == 200) {
                    if (response.data.Code == 1) {
                        return callBack(response.data);
                    } else {
                        that.$notify.error({
                            title: '失败',
                            message: response.data.Msg
                        });
                    }
                } else {
                    that.$notify.error({
                        title: '失败',
                        message: '修改失败'
                    });
                }
            })
            .catch(function(error) {
                if (error.response.status == 401) {
                    that.$router.replace({
                        name: 'Login'
                    });
                    return;
                }
                that.$store.state.loading = false;
                that.$notify.error({
                    title: '失败',
                    message: '网络错误'
                });
            });
    },
    apiDelete(that, url, callback) {
        url += "?api-version=1.0";
        that.$store.state.loading = true;
        axios.delete(url).then(function(response) {
                that.$store.state.loading = false;
                if (response.status == 200) {
                    if (response.data.Code == 1) {
                        return callBack(response.data);
                    } else {
                        that.$notify.error({
                            title: '删除',
                            message: '删除失败'
                        });
                    }
                } else {
                    that.$notify.error({
                        title: '失败',
                        message: '删除失败'
                    });
                }
            })
            .catch(function(error) {
                if (error.response.status == 401) {
                    that.$router.replace({
                        name: 'Login'
                    });
                    return;
                }
                that.$store.state.loading = false;
                that.$notify.error({
                    title: '失败',
                    message: '网络错误'
                });
            });
    },

    download(url) {
        return baseUrl + "Upload/" + url
    },





    //登录
    Login(that, data, callback) {
        var url = "admin/login?name=" + encodeURI(data.name) + "&password=" + data.password;
        this.apiGet(that, url, function(msg) {
            sessionStorage.setItem("userId", msg.Result.ADMIN_ID);
            sessionStorage.setItem("userRole", msg.Result.ADMIN_ROLE);
            sessionStorage.setItem("userPower", msg.Result.ADMIN_POWER);
            sessionStorage.setItem("userName", data.name);
            axios.defaults.headers.common['Authorization'] = "Basic " + Base64.encode(data.name + ":" + data.password);
            sessionStorage.setItem("Authorization", Base64.encode(data.name + ":" + data.password));
            setTimeout(() => {
                that.$router.replace({
                    name: 'Main'
                });
                that.loding = false;
            }, 300)
        })
    },

    LoginOut(that) {
        axios.defaults.headers.common['Authorization'] = "";
        sessionStorage.clear();
        //删除token
        that.$router.replace({
            path: "/"
        });
    },
    //获取 特定用户的渠道列表(包含admin)
    OrgnizationGetUserList(that, data, callback) {
        var url = "ORGANIZATION/GetUserList?pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize + "&userId=" + data.userId;

        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    //获取 用户信息包含用户推荐人姓名
    OrgnizationGetRelationModel(that, data, callback) {
        var url = 'ORGANIZATION/GetRelationModel?id=' + data.Id;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    //获取 所有的渠道列表(包含admin)
    OrgnizationGetList(that, data, callback) {
        var url = "ORGANIZATION/GetOrganizationHaveAdmin?pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    //新增渠道
    OrganizationAdd(that, data) {
        var url = "ORGANIZATION";
        this.apiPost(that, url, data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '添加成功'
            });
            that.$emit('close');
        })

    },
    //查询
    OrgnizationGet(that, data, callback) {
        var url = "ORGANIZATION?Id=" + data.Id;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    //修改
    OrgnizationChange(that, data) {
        var url = "ORGANIZATION";
        this.apiPut(that, url, data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '修改成功'
            });
            that.$emit('close');
        })
    },
    //多条件查询
    OrgnizationGetMutial(that, data, callback) {
        var url = "ORGANIZATION/SelectUserList?name=" + data.name + "&address=" + data.address + "&people=" +
            data.people + "&startTime=" + data.startTime + "&endTime=" + data.endTime +
            "&pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize + "&userId=" + data.userId;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    //获取待沟通提醒的 渠道列表
    OrgnizationGetRemainList(that, data, callback) {
        var url = "ORGANIZATION/GetRemainList?pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    //获取待沟通提醒的渠道列表 指定用户
    OrgnizationGetRemainListByUser(that, data, callback) {
        var url = "ORGANIZATION/GetRemainListByUser?userId=" + data.userId + "&pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    //获取 沟通记录
    RecordList(that, data, callback) {
        var url = "RECORD/RecordByTypeGet?type=" + data.type + "&id=" + data.id + "&pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    //新增沟通记录
    RecordAdd(that, data) {
        var url = "record/RecordAdd";
        this.apiPost(that, url, data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '添加成功'
            });
            that.$emit('close');
        })
    },
    //获取包含 用户信息的渠道列表 渠道、客户分配用
    GetOrganizationHaveAdmin(that, data, callback) {
        var url = "ORGANIZATION/GetOrganizationHaveAdmin?pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    //分配渠道
    ChangeOrganizationUser(that, data) {
        var url = "ORGANIZATION/ChangeOrganizationUser";
        this.apiPut(that, url, data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '修改成功'
            });
            that.Getdata();
        })
    },






    //获取 特定用户的客户列表
    CustomGetUserList(that, data, callback) {
        var url = "custom/GetUserList?pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize + "&userId=" + data.userId;

        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    //获取 所有的客户列表
    CustomGetList(that, data, callback) {
        var url = "custom/GetAllUserList?pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    //查询
    CustomGet(that, data, callback) {
        var url = "Custom/GetDto?Id=" + data.Id;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    //新增客户
    CustomAdd(that, data) {
        var url = "Custom";
        this.apiPost(that, url, data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '添加成功'
            });
            that.$emit('close');
        })

    },
    //修改
    CustomChange(that, data) {
        var url = "custom";
        this.apiPut(that, url, data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '修改成功'
            });
            that.$emit('close');
        })
    },
    //多条件查询
    CustomGetMutial(that, data, callback) {
        var url = "custom/SelectUserList?name=" + data.name + "&school=" + data.school + "&produce=" +
            data.produce + "&orgnization=" + data.orgnization + "&startTime=" + data.startTime + "&endTime=" + data.endTime +
            "&pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize + "&userId=" + data.userId;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    //根据渠道id 获取列表
    CustomGetByOrganizationId(that, data, callback) {
        console.log(data);
        var url = "custom/GetByOrganizationId?id=" + data.id + "&pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    //获取待沟通提醒的 客户列表
    CustomGetRemainList(that, data, callback) {
        var url = "custom/GetRemainList?pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    //获取待沟通提醒的 客户列表 指定用户
    CustomGetRemainListByUser(that, data, callback) {
        var url = "custom/GetRemainListByUser?userId=" + data.userId + "&pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    //获取用户
    AdminGetList(that, data, callback) {
        var url = "admin/GetSealUserList";
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    //获取没有机构的客户
    GetNoOrganzationList(that, data, callback) {
        var url = "custom/GetNoOrganzationList?pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    //分配渠道
    ChangeCustomUser(that, data) {
        var url = "custom/ChangeCustomUser";
        this.apiPut(that, url, data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '修改成功'
            });
            that.Getdata();
        })
    },
    /**
     * 系统管理
     */



    DOCTORSelectMultipel(that, data, callback) {
        var url = "DOCTOR/GetMultiple?pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize + "&name=" + data.name + "&address=" + data.address;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        });
    },
    DOCTORGetList(that, data, callback) {
        var url = "DOCTOR?pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        });
    },
    DOCTORAdd(that, data) {
        var url = "DOCTOR";
        this.apiPost(that, url, data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '添加成功'
            });
            that.$emit('close');
        })
    },
    DOCTORGetOne(that, data, callback) {
        var url = "DOCTOR?Id=" + data.Id;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    DOCTORUpdate(that, data) {
        var url = "DOCTOR";
        this.apiPut(that, url, data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '修改成功'
            });
            that.$emit('close');
        })
    },
    DOCTORSelectMultipel(that, data, callback) {
        var url = "DOCTOR/GetMultiple?name=" + data.name + "&address=" + data.address + "&pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        });
    },


    SAMUSelectMultipel(that, data, callback) {
        var url = "SAMU/GetMultiple?pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize + "&name=" + data.name + "&address=" + data.address;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        });
    },
    SAMUGetList(that, data, callback) {
        var url = "SAMU?pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        });
    },
    SAMUAdd(that, data) {
        var url = "SAMU";
        this.apiPost(that, url, data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '添加成功'
            });
            that.$emit('close');
        })
    },
    SAMUGetOne(that, data, callback) {
        var url = "SAMU?Id=" + data.Id;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    SAMUUpdate(that, data) {
        var url = "SAMU";
        this.apiPut(that, url, data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '修改成功'
            });
            that.$emit('close');
        })
    },
    SAMUSelectMultipel(that, data, callback) {
        var url = "SAMU/GetMultiple?name=" + data.name + "&address=" + data.address + "&pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        });
    },


    PHARMACYSelectMultipel(that, data, callback) {
        var url = "PHARMACY/GetMultiple?pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize + "&name=" + data.name + "&address=" + data.address;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        });
    },
    PHARMACYGetList(that, data, callback) {
        var url = "PHARMACY?pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        });
    },
    PHARMACYAdd(that, data) {
        var url = "PHARMACY";
        this.apiPost(that, url, data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '添加成功'
            });
            that.$emit('close');
        })
    },
    PHARMACYGetOne(that, data, callback) {
        var url = "PHARMACY?Id=" + data.Id;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    PHARMACYUpdate(that, data) {
        var url = "PHARMACY";
        this.apiPut(that, url, data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '修改成功'
            });
            that.$emit('close');
        })
    },
    PHARMACYSelectMultipel(that, data, callback) {
        var url = "PHARMACY/GetMultiple?name=" + data.name + "&address=" + data.address + "&pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        });
    },


    HOSPITALSelectMultipel(that, data, callback) {
        var url = "HOSPITAL/GetMultiple?pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize + "&name=" + data.name + "&address=" + data.address;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        });
    },
    HOSPITALGetList(that, data, callback) {
        var url = "HOSPITAL?pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        });
    },
    HOSPITALAdd(that, data) {
        var url = "HOSPITAL";
        this.apiPost(that, url, data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '添加成功'
            });
            that.$emit('close');
        })
    },
    HOSPITALGetOne(that, data, callback) {
        var url = "HOSPITAL?Id=" + data.Id;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    HOSPITALUpdate(that, data) {
        var url = "HOSPITAL";
        this.apiPut(that, url, data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '修改成功'
            });
            that.$emit('close');
        })
    },
    HOSPITALSelectMultipel(that, data, callback) {
        var url = "HOSPITAL/GetMultiple?name=" + data.name + "&address=" + data.address + "&pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        });
    },

    //文件上传
    uploadFile(that, data, callback) {
        this.apiPost(that, 'File', data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '上传成功'
            });
            return callback(msg);
        });
    },

    schoolAdd(that, data) {
        this.apiPost(that, "school/PostDto", data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '添加成功'
            });
            that.$emit('close');
        })
    },
    schoolGetList(that, data, callback) {
        var url = "school?pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        });
    },
    schoolSelectMultipel(that, data, callback) {
        var url = "school/GetMultiple?name=" + data.name + "&address=" + data.address + "&pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        });
    },
    schoolGetone(that, data, callback) {
        var url = "school/GetDto?Id=" + data.Id;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    //删除和学校关联的 医疗机构
    schoolDeletRelation(that, data, callback) {
        var url = "SCHOOL_MEDICALRESOURCE/DeleteOne?Id=" + data.Id + "&SId=" + data.SId;
        this.apiDelete(that, url, function(msg) {
            return callback(msg);
        })
    },
    //学校dto 更新
    schoolUpdate(that, data) {
        var url = "school/PutDto";
        this.apiPut(that, url, data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '修改成功'
            });
            that.$emit('close');
        })
    },



    //用户管理
    UserGetList(that, data, callback) {
        var url = "ADMIN?pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    // 新增
    UserAdd(that, data) {
        this.apiPost(that, "ADMIN", data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '添加成功'
            });
            that.$emit('close');
        })
    },
    //更加名字 查询
    UserGetByName(that, data, callback) {
        var url = "ADMIN/GetByName?pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize + "&name=" + data.name;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    //获取一个用户信息
    UserGetOne(that, data, callback) {
        var url = "ADMIN/" + data.Id;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    //修改
    UserUpdate(that, data) {
        var url = 'ADMIN';
        this.apiPut(that, url, data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '修改成功'
            });
        })
        that.$emit('close');
    },
    //重置密码
    UserPassWordRest(that, data) {
        var url = 'ADMIN/PassWordRest';
        this.apiPut(that, url, data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '重置密码成功'
            });
        })
    },
    //修改密码
    UserPasswordChange(that, data) {
        var url = 'ADMIN/PasswordChange';
        this.apiPut(that, url, data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '修改成功'
            });
            that.passwordchanger = false;
            that.loginout();
        })
    },


    //产品管理
    PRODUCEGetList(that, data, callback) {
        var url = "PRODUCE?pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        });
    },
    PRODUCEAdd(that, data) {
        var url = "PRODUCE";
        this.apiPost(that, url, data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '添加成功'
            });
            that.$emit('close');
        })
    },
    PRODUCEGetOne(that, data, callback) {
        var url = "PRODUCE?Id=" + data.Id;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    PRODUCEUpdate(that, data) {
        var url = "PRODUCE";
        this.apiPut(that, url, data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '修改成功'
            });
            that.$emit('close');
        })
    },



    //获取所有 责任类型
    IP_ITEMGetAll(that, callback) {
        var url = "dutyitem/GetAll";
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },

    //新增利益表
    BenifitAdd(that, data) {
        var url = 'Benifit/PostNew';
        this.apiPost(that, url, data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '添加成功'
            });
            that.$emit('close');
        })
    },
    BenfitGet(that, data, callback) {
        var url = 'Benifit/GetAll?Id=' + data.Id;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    BenfitUpdate(that, data) {
        var url = "Benifit/PutChange";
        this.apiPut(that, url, data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '修改成功'
            });
            that.$emit('close');
        })
    },

    /// 投保单
    //包含新用户
    SaledetailAddDto(that, data) {
        var url = "SALESDETAIL/AddDto";
        this.apiPost(that, url, data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '添加成功'
            });
            that.$emit('close');
            that.$router.replace({
                name: 'SellAdd'
            });
            // that.$router.replace("")
        })
    },
    //不包含新用户
    SaledetailAdd(that, data) {
        var url = "SALESDETAIL";
        this.apiPost(that, url, data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '添加成功'
            });
            that.$emit('close');
            that.$store.commit("changer", {});
        })
    },
    //通过状态获取
    SaledetailSelect(that, data, callback) {
        var url = 'SALESDETAIL/GetByState?state=' + data.state + "&pageSize=" + data.pageSize + "&pageIndex=" + data.pageIndex;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    //通过状态和名称获取
    SaledetailSelectByName(that, data, callback) {
        var url = 'SALESDETAIL/GetByName?state=' + data.state + "&pageSize=" + data.pageSize + "&pageIndex=" + data.pageIndex + "&name=" + data.name;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    SaledetailUpdate(that, data) {
        var url = "SALESDETAIL/UpdateDto";
        this.apiPut(that, url, data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '修改成功'
            });
            that.$emit('close');
            try {
                that.getDate();
            } catch (error) {}
        })
    },
    //部分更新
    SaledetailUpdatePart(that, data, callback) {
        var url = "SALESDETAIL";
        this.apiPut(that, url, data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '修改成功'
            });
            that.$emit('close');
            if (callback) {
                return callback(msg);
            }
            try {
                that.getDate();
                this.$refs.list.getDate();
                this.finace = false;
            } catch (error) {}
        })
    },
    //部分更新 结算佣金
    SaldetailMoney(that, data, callback) {
        var url = "SALESDETAIL/MoneyCustom";
        this.apiPut(that, url, data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '修改成功'
            });
            that.$emit('close');
            if (callback) {
                return callback(msg);
            }
            try {
                that.getDate();
                this.$refs.list.getDate();
                this.finace = false;
            } catch (error) {}
        })
    },
    //打印投保单
    SaledetailGetDoc(that, data, callback) {
        var url = "SALESDETAIL/GetDoc?id=" + data.id;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    //获取单个订单信息
    SaledetailGetDtoOne(that, data, callback) {
        var url = "SALESDETAIL/GetDtoOne?id=" + data.id;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    BACKSALEAdd(that, data) {
        var url = "BACKSALE/AddRelation";
        this.apiPost(that, url, data, function(msg) {
            that.$notify.success({
                title: '成功',
                message: '添加成功'
            });
            that.$emit('close');
        })
    },
    BACKSALEGetOne(that, data, callback) {
        var url = "BACKSALE/GetOne?id=" + data.Id;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    BACKSALEUpdate(that, data, callback) {
        var url = "BACKSALE/UpdateRelation";
        this.apiPut(that, url, data, function(msg) {
            return callback();
        })
    },
    ///财务功能  获取列表
    GetClearingList(that, data, callback) {
        var url = "SALESDETAIL/GetSearchDynimic?id=0";
        for (const key in data) {
            if (data.hasOwnProperty(key)) {
                if (data[key]) {
                    url += "&" + key + "=" + data[key];
                }
            }
        }
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    //获取 服务费账单
    GetServerMoney(that, data, callback) {
        var url = "file/ServerMoney";
        this.apiPut(that, url, data, function(msg) {
            return callback(msg);
        })
    },
    //获取列表 渠道结算 根据type 
    BrokerageList(that, data, callback) {
        var url = "BROKERAGE/list?type=" + data.type + "&timeStart=" + data.timeStart + "&timeEnd=" + data.timeEnd;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    //渠道确认 list
    BrokerageOrganzationList(that, data, callback) {
        var url = "BROKERAGE/OrganzationList?type=" + data.type + "&timeStart=" + data.timeStart + "&timeEnd=" + data.timeEnd;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    PutOrganizationMoney(that, data, callback) {
        var url = "file/OrganizationMoney";
        this.apiPut(that, url, data, function(msg) {
            return callback(msg);
        })
    },
    //批量确认
    BrokerageUpdateAll(that, data, callback) {
        var url = "BROKERAGE/UpdateAll";
        this.apiPut(that, url, data, function(msg) {
            return callback(msg);
        })
    },
    //佣金退保更新
    BrokerUpdate(that, data, callback) {
        var url = "BROKERAGE";
        this.apiPut(that, url, data, function(msg) {
            return callback(msg);
        })
    },
    ///需要退保处理的 渠道佣金列表
    GetBackBrokerageList(that, data, callback) {
        var url = "BROKERAGE/BackBrokerageList"
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },


    //下载 佣金
    GetCommission(that, data, callback) {
        var url = "file/Commission";
        this.apiPut(that, url, data, function(msg) {
            return callback(msg);
        })
    },
    //下载 有效保单
    Getvliad(that, data, callback) {
        var url = "file/vliad";
        this.apiPut(that, url, data, function(msg) {
            return callback(msg);
        })
    },
    PutCenter(that, data, callback) {
        var url = "COMPANYMONEY/Center";
        this.apiPut(that, url, data, function(msg) {
            return callback(msg);
        })
    },
    //获取列表 新
    GetCOMPANYMONEYList(that, data, callback) {
        var url = "COMPANYMONEY/List?pageIndex=" + data.pageIndex + "&pageSize=" +
            data.pageSize + "&type=" + data.type + "&stateTime=" + data.stateTime +
            "&endTime=" + data.endTime + "&company=" + data.company;
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    //佣金结算记录 修改
    GetCOMPANYBROKERAGEList(that, data, callback) {
        var url = "COMPANYBROKERAGE?pageIndex=" + data.pageIndex + "&pageSize=" + data.pageSize
        this.apiGet(that, url, function(msg) {
            return callback(msg);
        })
    },
    GetCOMPANYBROKERAGEUpdate(that, data, callback) {
        var url = "COMPANYBROKERAGE";
        this.apiPut(that, url, data, function(msg) {
            return callback(msg);
        })
    }
};